package com;

/***
 * 关于锁粒度的问题一定要注意
 */
public class T {
    public static void main(String[] args) {
        TTTT t = new TTTT();
        t.tt();
        new Thread(() -> t.t2()).start();
        new Thread(() -> t.t3()).start();
        new Thread(() -> t.t4()).start();
    }
}

class TTTT {
    public synchronized void t2() {
        System.out.println("t2");
    }

    public synchronized void t3() {
        System.out.println("t3");
    }

    public synchronized void t4() {
        System.out.println("t4");
    }

    public synchronized void tt() {
        for (int i = 0; i < 50; i++) {
            try {
                Thread.sleep(100);
                System.out.println("--------");
            } catch (InterruptedException e) {
                e.printStackTrace();
            }
        }
        System.out.println("tt");
    }


}
